#include <stdio.h>
#include <math.h>

int countNum(int num)
{
	if (num == 0)return 1;
	int count = 0;
	while (num)
	{
		num /= 10;
		count++;
	}
	return count;
}

int isCount(int num)
{
	int num1 = num;
	int sum = 0;
	int count = countNum(num);
	while (num)
	{
		int value = pow(num % 10, count);
		sum += value;
		num /= 10;
	}
	return sum == num1;
}

int main()
{
	for (int i = 0; i <= 100000; i++)
	{
		if (isCount(i))
		{
			printf("%d\n", i);
		}
	}

	return 0;
}